home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2248 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  655 b 

  1. Path: news.goodnet.com!goodguy!geoff
  2. From: geoff@goodguy (GEOFF CADIEN)
  3. Newsgroups: comp.lang.c++
  4. Subject: overloading []
  5. Date: 16 Jan 1996 16:22:13 GMT
  6. Organization: GoodNet
  7. Message-ID: <4dgjbl$6i3@news1.goodnet.com>
  8. NNTP-Posting-Host: goodnet.com
  9. X-Newsreader: TIN [version 1.2 PL2]
  10.  
  11.  
  12. Here is my question.  I have a class foo in which I have overloaded the
  13. array subscript operator. I have no problem doing something like this:
  14.  
  15. foo f;
  16.  
  17. f[1] = 10;
  18.  
  19. my problem is this. Given,
  20.  
  21. foo *f;
  22.  
  23. f = new foo;
  24.  
  25. Now the only way I can use the subscript operator is to call it like this
  26.  
  27. f->operator[](1) = 10;
  28.  
  29. Is this the only way?
  30.  
  31. Geoff Cadien
  32. geoff@goodnet.com
  33.